
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>Executor与Statement的管理 - 学习卡片</title>
      <style>
        body { font-family: sans-serif; background-color: #f0f8ff; color: #333; display: flex; flex-direction: column; align-items: center; padding: 50px 20px; }
        .header h1 { font-size: 32px; }
        .grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; width: 100%; max-width: 1200px; }
        .card-container { perspective: 1200px; cursor: pointer; height: 250px; }
        .card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.7s; border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
        .card-container.flipped .card { transform: rotateY(180deg); }
        .card-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; box-sizing: border-box; border-radius: 16px; background-color: #fff; padding: 24px; }
        .card-back { background-color: #f0fff4; transform: rotateY(180deg); justify-content: space-between; }
        .card-category { font-size: 14px; color: #0052d9; margin-bottom: 8px; font-weight: 500; }
        .card-question { font-size: 20px; font-weight: 500; flex-grow: 1; display: flex; align-items: center; justify-content: center; text-align: center; }
        .card-answer-wrapper { flex-grow: 1; overflow-y: auto; }
        .card-answer { font-size: 15px; line-height: 1.7; }
        .card-footer { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 16px; margin-top: 16px; }
        .card-source { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 12px; margin-top: 12px; }
      </style>
    </head>
    <body>
      <div class="header">
        <h1>Executor与Statement的管理 - 学习卡片</h1>
      </div>
      <div class="grid-container">
        
    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">理论</div>
          <div class="card-question">在MyBatis中，Executor和Statement的核心职责分别是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">理论</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Executor负责执行SQL语句的调度，是数据库操作的核心调度者。而Statement是执行SQL语句的具体工具，由Executor通过StatementHandler来创建和管理。</div>
          </div>
          <div class="card-source">来源: 文档引言及「3. StatementHandler与Statement的关系」部分</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">MyBatis的Executor组件主要承担哪些职责？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Executor的职责包括：执行SQL语句并获取结果集；处理SQL语句的缓存；管理事务的提交与回滚；以及支持不同的执行策略（如简单执行、复用执行、批量执行）。</div>
          </div>
          <div class="card-source">来源: 1. Executor的职责与功能</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">MyBatis中最常用的三种Executor实现类是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">最常用的三种Executor实现类是：SimpleExecutor、ReuseExecutor和BatchExecutor。</div>
          </div>
          <div class="card-source">来源: 1. Executor的职责与功能</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">简述MyBatis中Executor的典型执行流程。</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">典型的执行流程始于创建SqlSession，此时会初始化一个Executor。接着，根据配置选择Executor类型。当调用如selectList()等方法时，Executor会委托StatementHandler创建并执行Statement，最后获取结果集并返回。</div>
          </div>
          <div class="card-source">来源: 2. Executor的执行流程</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">理论</div>
          <div class="card-question">StatementHandler在MyBatis的执行体系中扮演什么角色？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">理论</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">StatementHandler是Executor和Statement之间的桥梁，它负责根据SQL语句和参数生成对应的Statement对象，并为Statement设置参数，最终执行SQL语句并返回结果。</div>
          </div>
          <div class="card-source">来源: 3. StatementHandler与Statement的关系</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">Executor是如何参与到MyBatis的事务管理中的？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Executor与事务管理紧密关联。它负责执行事务的提交与回滚操作。当SQL操作成功时，Executor会提交事务；如果出现异常，则回滚事务。同时，它也确保多个SQL操作能在同一个事务中执行。</div>
          </div>
          <div class="card-source">来源: 4. 事务管理与Executor</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">MyBatis中的一级缓存（Level 1 Cache）的作用范围是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">一级缓存的作用范围仅限于SqlSession级别。这意味着在同一个SqlSession实例内，如果重复执行相同的查询，MyBatis会直接从缓存中返回结果，而不会再次向数据库发起请求。</div>
          </div>
          <div class="card-source">来源: 5. Statement的创建与缓存</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">与默认的SimpleExecutor相比，ReuseExecutor是如何优化性能的？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">ReuseExecutor通过复用Statement对象来优化性能。它会在同一个SqlSession中缓存已经创建的Statement对象。当执行相同的SQL时，它会直接使用缓存的Statement，从而避免了像SimpleExecutor那样每次都创建新对象的开销。</div>
          </div>
          <div class="card-source">来源: 6. ReuseExecutor与Statement复用</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">BatchExecutor的主要应用场景是什么？它是如何提升性能的？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">BatchExecutor主要用于处理批量的SQL执行操作。它将多个SQL语句组合在一起，一次性提交到数据库执行，通过减少数据库的交互次数来提升性能。</div>
          </div>
          <div class="card-source">来源: 7. BatchExecutor与批量执行</div>
        </div>
      </div>
    </div>

      </div>
    </body>
    </html>
